package com.nari.ncps.screen.service.impl.ne;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nari.ncps.screen.entity.ne.NePopupNetOutput;
import com.nari.ncps.screen.entity.ne.NePopupSafe;
import com.nari.ncps.screen.mapper.ne.NePopupNetOutputMapper;
import com.nari.ncps.screen.service.ne.NePopupNetOutputService;
import com.nari.ncps.screen.vo.ne.WindGridPowerVO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 实时上网电量及购网电量 服务实现类
 * </p>
 *
 * @author dongxiaoxu
 * @since 2025-11-04
 */
@Service
public class NePopupNetOutputServiceImpl extends ServiceImpl<NePopupNetOutputMapper, NePopupNetOutput> implements NePopupNetOutputService {

    @Override
    public WindGridPowerVO getWindGridPower(String orgCode) {
        if(orgCode==null){
            orgCode = "134058";
        }
        WindGridPowerVO vo = new WindGridPowerVO();
        LambdaQueryWrapper<NePopupNetOutput> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(NePopupNetOutput::getDelFlag, 0)
                .eq(NePopupNetOutput::getOrgCode, orgCode)
                .eq(NePopupNetOutput::getDateType, 0);
        NePopupNetOutput result = this.getOne(queryWrapper);
        if (result==null){
            return new WindGridPowerVO();
        }else {
            vo.setPurchasePower(result.getGridSupplyPower());
            vo.setGridPower(result.getGridPurchasePower());
        }
        return vo;
    }
}
